/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author adama
 */
@Entity
@Table(name = "video")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Video.findAll", query = "SELECT v FROM Video v"),
    @NamedQuery(name = "Video.findByIdVideo", query = "SELECT v FROM Video v WHERE v.idVideo = :idVideo"),
    @NamedQuery(name = "Video.findByTitre", query = "SELECT v FROM Video v WHERE v.titre = :titre"),
    @NamedQuery(name = "Video.findByDuree", query = "SELECT v FROM Video v WHERE v.duree = :duree"),
    @NamedQuery(name = "Video.findByAnnee", query = "SELECT v FROM Video v WHERE v.annee = :annee"),
    @NamedQuery(name = "Video.findByPays", query = "SELECT v FROM Video v WHERE v.pays = :pays"),
    @NamedQuery(name = "Video.findByCategorie", query = "SELECT v FROM Video v WHERE v.categorie = :categorie"),
    @NamedQuery(name = "Video.findByLien", query = "SELECT v FROM Video v WHERE v.lien = :lien"),
    /* Ajout trie sur les 100 dernière vidéos*/
    @NamedQuery(name = "Video.NouvellesVideo", query = "SELECT v FROM Video v ORDER BY v.lien WHERE LIMIT = '100'")})
public class Video implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Lob
    @Column(name = "Image")
    private byte[] image;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DateCreation")
    @Temporal(TemporalType.DATE)
    private Date dateCreation;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Date")
    @Temporal(TemporalType.DATE)
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idVideo")
    private Integer idVideo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "Titre")
    private String titre;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Duree")
    @Temporal(TemporalType.TIME)
    private Date duree;
    @Column(name = "Annee")
    @Temporal(TemporalType.DATE)
    private Date annee;
    @Lob
    @Size(max = 65535)
    @Column(name = "Description")
    private String description;
    @Size(max = 8)
    @Column(name = "Pays")
    private String pays;
    @Size(max = 35)
    @Column(name = "Categorie")
    private String categorie;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "Lien")
    private String lien;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "video")
    private Collection<Relationvideoplaylist> relationvideoplaylistCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "video")
    private Collection<Relationvideoartiste> relationvideoartisteCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "video")
    private Collection<Saison> saisonCollection;

    public Video() {
    }

    public Video(Integer idVideo) {
        this.idVideo = idVideo;
    }

    public Video(Integer idVideo, String titre, Date duree, String lien, byte[] image) {
        this.idVideo = idVideo;
        this.titre = titre;
        this.duree = duree;
        this.lien = lien;
        this.image = image;
    }

    public Integer getIdVideo() {
        return idVideo;
    }

    public void setIdVideo(Integer idVideo) {
        this.idVideo = idVideo;
    }

    public String getTitre() {
        return titre;
    }

    public void setTitre(String titre) {
        this.titre = titre;
    }

    public Date getDuree() {
        return duree;
    }

    public void setDuree(Date duree) {
        this.duree = duree;
    }

    public Date getAnnee() {
        return annee;
    }

    public void setAnnee(Date annee) {
        this.annee = annee;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPays() {
        return pays;
    }

    public void setPays(String pays) {
        this.pays = pays;
    }

    public String getCategorie() {
        return categorie;
    }

    public void setCategorie(String categorie) {
        this.categorie = categorie;
    }

    public String getLien() {
        return lien;
    }

    public void setLien(String lien) {
        this.lien = lien;
    }

    @XmlTransient
    public Collection<Relationvideoplaylist> getRelationvideoplaylistCollection() {
        return relationvideoplaylistCollection;
    }

    public void setRelationvideoplaylistCollection(Collection<Relationvideoplaylist> relationvideoplaylistCollection) {
        this.relationvideoplaylistCollection = relationvideoplaylistCollection;
    }

    @XmlTransient
    public Collection<Relationvideoartiste> getRelationvideoartisteCollection() {
        return relationvideoartisteCollection;
    }

    public void setRelationvideoartisteCollection(Collection<Relationvideoartiste> relationvideoartisteCollection) {
        this.relationvideoartisteCollection = relationvideoartisteCollection;
    }

    @XmlTransient
    public Collection<Saison> getSaisonCollection() {
        return saisonCollection;
    }

    public void setSaisonCollection(Collection<Saison> saisonCollection) {
        this.saisonCollection = saisonCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idVideo != null ? idVideo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Video)) {
            return false;
        }
        Video other = (Video) object;
        if ((this.idVideo == null && other.idVideo != null) || (this.idVideo != null && !this.idVideo.equals(other.idVideo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Video[ idVideo=" + idVideo + " ]";
    }

    public byte[] getImage() {
        return image;
    }

    public void setImage(byte[] image) {
        this.image = image;
    }

    public Date getDateCreation() {
        return dateCreation;
    }

    public void setDateCreation(Date dateCreation) {
        this.dateCreation = dateCreation;
    }
    
}
